<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateWithdrawsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('withdraws', function (Blueprint $table) {
            $table->id();
            $table->integer('store_id')->default(0)->comment('店铺id');
            $table->integer('user_id')->unsigned()->comment('用户id');
            $table->string('bank_name')->default('')->comment('提现银行');
            $table->string('bank_code')->default('')->comment('银行卡号');
            $table->string('deposit')->default('')->comment('开户行');
            $table->string('accepter_name')->default('')->comment('提现人名字');
            $table->string('accepter_phone')->default('')->comment('提现人手机');
            $table->integer('withdraw')->unsigned()->default(0)->comment('提现金额，单位分');
            $table->integer('service_fee')->unsigned()->default(0)->comment('提现手续费，单位分');
            $table->tinyInteger('status')->default(0)->comment('提现状态: 0 待审核 / 1 已通过 / 2 已拒绝');
            $table->datetime('apply_at')->nullable()->comment('申请时间');
            $table->datetime('examine_at')->nullable()->comment('审核时间');
            $table->datetime('refuse_at')->nullable()->comment('拒绝时间');
            $table->string('why')->default('')->comment('拒绝原因');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `withdraws` comment '提现记录表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('withdraws');
    }
}
